<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>
<html>
<script type="text/javascript" src="js/utils.js"></script>
<LINK REL="StyleSheet" HREF="css/style.css" TYPE="text/css" />
<LINK REL="StyleSheet" HREF="css/principal.css" TYPE="text/css" />
<script type="text/javascript" src="js/calendar/PopupWindow.js"></script>
<script type="text/javascript" src="js/calendar/CalendarPopup.js"></script>
<script type="text/javascript" src="js/calendar/AnchorPosition.js"></script>
<script type="text/javascript" src="js/calendar/date.js"></script>
<script type="text/javascript">
		var calFechaNacimiento = new CalendarPopup("fechabushel");
    	calFechaNacimiento.showNavigationDropdowns();
   		calFechaNacimiento.setCssPrefix("TEST");
    	calFechaNacimiento.setYearSelectStartOffset(80);
   		
   		function openCalendar(dateField){
			calFechaNacimiento.select(dateField,'img_busheldate','dd/MM/yyyy'); 
			return false;
   		}

	   	function validate(){
	         var errors = "";                
	         
	         var amount = document.getElementById('bushelPriceView.amount').value;        
	 		 var date   = document.getElementById('bushelPriceView.date').value;
	                       
	         if(amount == "" || parseInt( amount ) == 0) {
	         	errors += ' <bean:message key="warning.message.manualcharge.amont"/>\n';
	         }
	         if(trim(date) == ""){                
	         	errors += ' <bean:message key="error.message.futurepurchase.wrong.empy"/>\n';			  
	         }else if(!isValidDate(trim(date))){
	         	errors += ' <bean:message key="error.message.futurepurchase.wrong.date"/>\n';
	         }
	         if( errors == "" ){
	             return true;
	         }else{
	             alert( '<bean:message key="label.common.errors"/> : \n' + errors );
	 			return false;
	         }
	     }
</script>

<html:form action="/saveBushelPrice" onsubmit="return validate();" method="POST">
<DIV ID="fechabushel"
	STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>

	<table width="30%" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
		<tr>
			<th colspan="2" align="center" class="titulocolumna"> <bean:message key="menu.module.corn.bushel.price" /> </th>			 
		</tr>
		<tr>
			<td class="etiqueta" width="50%"><bean:message key="label.bushelprice.amount" />:</td>
			<td class="etiqueta_campo" width="50%">
				<html:text styleClass="columnanumero" style="width:110px;" property="bushelPriceView.amount" styleId="reference" onkeydown="return (numeric(event, 1) && noPaste(event, this));" onkeyup="extractNumber(this,4,false);"  onclick="this.focus()"></html:text>
			</td>
		</tr>
		<tr>
			<td class="etiqueta" width="50%"><bean:message key="label.bushelprice.fecha" />:</td>
			<td class="etiqueta_campo" width="50%">
				<html:text styleId='date' styleClass="columnanumero" property="bushelPriceView.date" style="width:110px" onclick="this.focus()" />
				<a href="javascript:var obj_dummy = openCalendar(document.getElementById('date'));"
					class="pointerhand" NAME="img_busheldate" ID="img_busheldate">
					<img id="fechatrigger" src="images/calendar.gif" border="0" />
				</a> 
				
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center" class="columnadatoPar">
				<html:submit styleClass="boton"><bean:message key="label.common.save"/></html:submit>				
				&nbsp;&nbsp;&nbsp;&nbsp;<html:button styleClass="boton" property="backButton" onclick="location.href='bushelPriceList.do';"><bean:message key="label.common.cancel"/></html:button>
			</td>
		</tr>		
	</table>
	</html:form>
	
</html>
